import { defineStore } from 'pinia'
import { pinia } from '@/store/index'
import { useUserStoreWithOut } from '@/store/modules/user'
import { HomeSet } from '@/api/login/types'

export interface MenuStore {
  menuTabRouters: AppRouteRecordRaw[]
}
const userStore = useUserStoreWithOut()

export const useMenuStore = defineStore('menuStore', {
  state: (): MenuStore => ({
    menuTabRouters: []
  }),
  getters: {
    getRouters(): AppRouteRecordRaw[] {
      return userStore.power
    },
    getHome(): HomeSet {
      return userStore.home
    },
    getMenuTabRouters(): AppRouteRecordRaw[] {
      return this.menuTabRouters
    }
  },
  actions: {
    setMenuTabRouters(routers: AppRouteRecordRaw[]): void {
      this.menuTabRouters = routers
    }
  }
})

export const useMenuStoreWithOut = () => {
  return useMenuStore(pinia)
}
